package app.caretrack.model;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "Alarms")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Alarm {
    private int id;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public int getId() {
        return this.id;
    }

    public void setId(int id) {
        this.id = id;
    }

    private Service service;

    private List<AlarmEvent> alarmEventList;

    @ManyToOne(fetch = FetchType.LAZY)
    public Service getService() {
        return this.service;
    }

    public void setService(Service service) {
        this.service = service;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "alarm", cascade = CascadeType.REMOVE)
    public List<AlarmEvent> getAlarmEventList() {
        return this.alarmEventList;
    }

    public void setAlarmEventList(List<AlarmEvent> alarmEventList) {
        this.alarmEventList = alarmEventList;
    }

}
